const states = {
  menuCollapse: false,
  device: 'pc',
  showMenus: false,
  i18n: {}
}

const mutations = {
  SET_MENUCOLLAPSE: (state, setting) => {
    state.menuCollapse = setting
  },
  SET_DEVICE: (state, setting) => {
    state.device = setting
  },
  SET_SHOWMENUS: (state, setting) => {
    state.showMenus = setting
  },
  SET_I18N: (state, setting) => {
    state.i18n = setting
  }
}

const actions = {
  setMenucollapse({ commit }, setting) {
    commit('SET_MENUCOLLAPSE', setting)
  },
  setDevice({ commit }, setting) {
    commit('SET_DEVICE', setting)
  },
  setShowMenus({ commit }, setting) {
    commit('SET_SHOWMENUS', setting)
  },
  setI18n({ commit }, setting) {
    commit('SET_I18N', setting)
    localStorage.setItem('lang', setting.name)
  }
}

export default {
  namespaced: true,
  state: states,
  mutations,
  actions
}
